package com.uniledger.exchange.model;

import android.content.Context;
import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;
import com.uniledger.exchange.R;
import com.uniledger.exchange.contact.UniContact;

public class TrxHistory {

    public int id;
    public String state;
    public String src_currency;
    public String src_amount;
    public String dst_currency;
    public String dst_amount;
    public int cashflow;
    public String category;
    public String datetime;

    public String getCategory(Context context) {
        if (TextUtils.equals("0", category)) {//转账
            if (cashflow == 0) {
                return getStr(context, R.string.bill_label_transfer);
            } else {
                return getStr(context, R.string.bill_label_receive);
            }
        } else if (TextUtils.equals("1", category)) {//提现
            return getStr(context, R.string.bill_label_withdraw);
        } else if (TextUtils.equals("2", category)) {//提现
            return getStr(context, R.string.bill_label_topup);
        } else if (TextUtils.equals("3", category)) { //支付
            if (cashflow == 0) {
                return getStr(context, R.string.bill_label_pay);
            } else {
                return getStr(context, R.string.bill_label_receive);
            }
        } else {
            return category;
        }
    }

    private String getStr(Context context, int id) {
        return String.format(context.getResources().getString(id), contact.nick);
    }

    @SerializedName("counterpart_info")
    public UniContact contact;

    public String getSrcAmount() {
        return String.format("%.2f", Float.parseFloat(src_amount));
    }
}
